package io.r2mo.test.common;

import cn.hutool.core.codec.Base64Encoder;
import io.r2mo.base.dbe.syntax.QTree;
import io.r2mo.spi.SPI;
import io.r2mo.spring.junit5.AppIoTestSupport;
import io.r2mo.test.TestDate;
import io.r2mo.typed.json.JObject;
import org.junit.jupiter.api.Test;

/**
 * @author lang : 2025-09-07
 */
public class DbAnalyzerTestCase extends AppIoTestSupport {

    @Test
    public void testDate() {
        final JObject condition = this.fs().inJson("HFS/data.json");
        final TestDate testDate = SPI.V_UTIL.deserializeJson(condition, TestDate.class);
        System.out.println(testDate);
        final JObject serJson = SPI.V_UTIL.serializeJson(testDate);
        System.out.println(serJson.encodePretty());
    }

    @Test
    public void testQr1() {
        final JObject condition = this.fs().inJson("HFS/source/condition/qr-1.json");
        final QTree tree = QTree.of(condition);
        System.out.println(tree);
    }

    @Test
    public void testQr2() {
        final JObject condition = this.fs().inJson("HFS/source/condition/qr-2.json");
        final QTree tree = QTree.of(condition);
        System.out.println(tree);
    }

    @Test
    public void testQr3() {
        final JObject condition = this.fs().inJson("HFS/source/condition/qr-3.json");
        final QTree tree = QTree.of(condition);
        System.out.println(tree);
    }

    @Test
    public void testQr4() {
        final JObject condition = SPI.SPI_OBJECT.jsonObject();
        condition.put("type", "MARKET");
        condition.put("", false);
        condition.put("$1", SPI.J()
            .put("type,<>", "EXTERNAL"));
        final QTree tree = QTree.of(condition);
        System.out.println(tree);
    }

    @Test
    public void testBase() {
        System.out.println(Base64Encoder.encode("admin:123456"));
    }
}
